<?php 
$jobids = json_decode($_['jobids']);
$alljobids = $_['alljobids'];
$action = $_['action'];
$sourcelist = $_['sourcelist'];
$thirdaccounts_info = $_['thirdaccounts_info'];
$thirdaccounts_status = $_['thirdaccounts_status'];
$thirdaccount_51job = empty($thirdaccounts_info['51job']) ? null : $thirdaccounts_info['51job'];
$thirdaccount_zhilian = empty($thirdaccounts_info['zhilian']) ? null : $thirdaccounts_info['zhilian'];
$thirdaccount_jiancai = empty($thirdaccounts_info['jiancai']) ? null : $thirdaccounts_info['jiancai'];
$thirdaccount_lagou = empty($thirdaccounts_info['lagou']) ? null : $thirdaccounts_info['lagou'];
$thirdaccount_status_51job = empty($thirdaccounts_status['51job']['fetchjobs']) ? null : $thirdaccounts_status['51job']['fetchjobs'];
$thirdaccount_status_zhilian = empty($thirdaccounts_status['zhilian']['fetchjobs']) ? null : $thirdaccounts_status['zhilian']['fetchjobs'];
$thirdaccount_status_jiancai = empty($thirdaccounts_status['jiancai']['fetchjobs']) ? null : $thirdaccounts_status['jiancai']['fetchjobs'];
$thirdaccount_status_lagou = empty($thirdaccounts_status['lagou']['fetchjobs']) ? null : $thirdaccounts_status['lagou']['fetchjobs'];

//check login status: 1.password  2.result != error 3.result != captcha
$login_status_51job  = (!empty($thirdaccount_51job['password']) && (isset($thirdaccounts_status['51job']['result']) && $thirdaccounts_status['51job']['result'] != 'error' && $thirdaccounts_status['51job']['result'] != 'captcha')) ? 1: 0;
$login_status_zhilian  = (!empty($thirdaccount_zhilian['password']) && (isset($thirdaccounts_status['zhilian']['result']) && $thirdaccounts_status['zhilian']['result'] != 'error' && $thirdaccounts_status['zhilian']['result'] != 'captcha')) ? 1: 0;
$login_status_jiancai  = (!empty($thirdaccount_jiancai['password']) && (isset($thirdaccounts_status['jiancai']['result']) && $thirdaccounts_status['jiancai']['result'] != 'error' && $thirdaccounts_status['jiancai']['result'] != 'captcha')) ? 1: 0;
$login_status_lagou  = (!empty($thirdaccount_lagou['password']) && (isset($thirdaccounts_status['lagou']['result']) && $thirdaccounts_status['lagou']['result'] != 'error' && $thirdaccounts_status['lagou']['result'] != 'captcha')) ? 1: 0;

$wuyoujobids = '';
$zhilianjobids = '';
$lagoujobids = '';
$jiancaijobids = '';
$pipapaijobids = '';

if(isset($sourcelist['51job']) && count($sourcelist['51job'])>0){
   $wuyoujobids = implode(',',$sourcelist['51job']);
}

if(isset($sourcelist['zhilian']) && count($sourcelist['zhilian'])>0){
   $zhilianjobids = implode(',',$sourcelist['zhilian']);
}

if(isset($sourcelist['lagou']) && count($sourcelist['lagou'])>0){
   $lagoujobids = implode(',',$sourcelist['lagou']);
}

if(isset($sourcelist['jiancai']) && count($sourcelist['jiancai'])>0){
   $jiancaijobids = implode(',',$sourcelist['jiancai']);
}

if(isset($sourcelist['pipapai']) && count($sourcelist['pipapai'])>0){
   $pipapaijobids = implode(',',$sourcelist['pipapai']);
}

$renewjobids = $wuyoujobids.','.$zhilianjobids.','.$lagoujobids.','.$jiancaijobids.','.$pipapaijobids;

$renewjobsnum = count(array_unique(array_filter(explode(',',$renewjobids))));


if(count($alljobids) == count($jobids)){
   if(count($jobids) == $renewjobsnum){
      if(count($jobids) == 1){
         $msg = "您将在枇杷派本站刷新该职位，并可同时刷新第三方网站";
      }else{
         $msg = "您将在枇杷派本站刷新".count($jobids)."个职位，并可同时刷新第三方网站";
      }
   }else{
      $msg = "您将在枇杷派本站刷新".$renewjobsnum."个职位（其它".(count($jobids)-$renewjobsnum)."个职位当天已刷新，不能再次刷新）";
   }
}else{
   $msg = "您将在枇杷派本站刷新".count($jobids)."个职位（其它".(count($alljobids)-count($jobids))."个职位没有管理权限）";
}

$totaljobids = count($jobids);

$jobids = implode(',', $jobids);
?>


<form id="jobposition_renewform" method="post" action="<?php echo ($action == 'renewjobs') ? OC_Helper::linkToRoute('jobpos_renewjob'): ''; ?>">
<?php if($action == 'renewjobs'): ?>
<div class="modal-header">
   <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
   <h3>刷新职位</h3>
</div>
<?php if($renewjobsnum>0){ ?>
<div class="modal-body">
   <div class="refreshtip_words <?php if(empty($wuyoujobids) && empty($zhilianjobids) && empty($jiancaijobids) && empty($lagoujobids)){echo 'nodataline';}?>">
      <i></i> <b><?php echo $msg; ?></b>
   </div>
   <?php if(!empty($wuyoujobids) || !empty($zhilianjobids) || !empty($jiancaijobids) || !empty($lagoujobids)):?>
   <div class="refresh_sync">
      <div class="refresh_synctitle">同时刷新：</div>
      <div class="refresh_syncselect">
         <?php if(!empty($wuyoujobids)): ?>
         <label data-source="51job" id="" class="checkbox inline sync_ctl">
            <input type="checkbox" data-source="51job" class="renewjob"> 
            <div style="width:82px;" class="synchronous_info"><i class="config_51"></i>&nbsp;前程无忧</div>
         </label>
         <?php endif; ?>
         <?php if(!empty($zhilianjobids)): ?>
         <label data-source="zhilian" id="" class="checkbox inline sync_ctl">
            <input type="checkbox" data-source="zhilian" class="renewjob"> 
            <div style="width:82px;" class="synchronous_info"><i class="config_zhilian"></i>&nbsp;智联招聘</div>
         </label>
         <?php endif; ?>
         <?php if(!empty($lagoujobids)): ?>
         <label data-source="lagou" id="" class="checkbox inline sync_ctl">
            <input type="checkbox" data-source="lagou" class="renewjob"> 
            <div style="width:55px;" class="synchronous_info"><i class="config_lagou"></i>&nbsp;拉勾</div>
            <!--<div style="width:55px;" class="synchronous_info synchronous_info_gray"><i class="config_lagou_gray"></i>&nbsp;拉勾</div>-->
         </label>
         <?php endif; ?>
         <?php if(!empty($jiancaijobids)): ?>
         <label data-source="jiancai" id="" class="checkbox inline sync_ctl">
            <input type="checkbox" data-source="jiancai" class="renewjob"> 
            <div style="width:82px;" class="synchronous_info"><i class="config_jianzhu"></i>&nbsp;建筑英才</div>
         </label>
         <?php endif; ?>
      </div>
   </div>
   <?php endif; ?>
</div>
<div class="modal-footer">
   <?php if($_['masteruser']):?>
   <em>小贴士：您还可以把职位设为<b>自动刷新</b>哦</em>
   <a href="<?php echo OC_Helper::linkToRoute('company_synchronousinfo');?>" class="settingbtn">立即设置</a>
   <?php endif; ?>
   <a href="javascript:;" class="btn btn-info">确定</a>
   <a href="javascript:;" class="btn cancel">取消</a>
</div>
<?php }else{ ?>
<div class="modal-body">
   <div class="refreshtip_words nodataline">
      <i></i> <b>您所选职位当天已刷新，不能再次刷新！</b>
   </div>
</div>
<?php } ?>

<?php else: ?>

<div class="modal-header">
 <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
 <h3>自动刷新</h3>
</div>
<div class="modal-body">
 <div class="ciw_words"><i></i> 确认将<?=$totaljobids ?>个职位设为自动刷新吗？</div>
</div>
<div class="modal-footer">
 <a id="saveautorenewjobs" href="javascript:;" class="btn btn-info">确认</a>
 <a href="javascript:;" class="btn cancel">取消</a>
</div>
  
<?php endif; ?>

<input type="hidden" value="<?=$jobids ?>" name="jobids">
<input type="hidden" value="<?=$jiancaijobids ?>" data-loginstatus="<?=$login_status_jiancai ?>" name="jobids_jiancai">
<input type="hidden" value="<?=$wuyoujobids ?>"  data-loginstatus="<?=$login_status_51job ?>" name="jobids_51job">
<input type="hidden" value="<?=$zhilianjobids ?>"  data-loginstatus="<?=$login_status_zhilian ?>" name="jobids_zhilian">
<input type="hidden" value="<?=$lagoujobids ?>"  data-loginstatus="<?=$login_status_lagou ?>" name="jobids_lagou">
<input name="requesttoken" value="<?=$_['requesttoken']?>" id="requesttoken" type="hidden">
</form>

